﻿@using Pro260Website.Areas.Admin.Models
@model Pro260Website.Models.ListingViewModel<Domain.Entity.Account>

@{
    ViewBag.Title = "User Management Panel";
    Layout = "~/Views/Shared/_PanelLayout.cshtml";
}
<h1 class="title @Html.GetColor(Request.Cookies["color"])">User Management Panel</h1>

<h1>@ViewBag.Message</h1>
<br/>
<table style="text-align: center; width: 900px;" class="defaultGrey">
            <tr class="tHeader @Html.GetColor(Request.Cookies["color"])">
                <th>Username</th>
                <th>Role</th>
                <th>Date Of Birth</th>
                <th>Joined On</th>
                <th>Last Visit On</th>
                <th>Security</th>
            </tr>
            @foreach (var c in Model.Items)
            {
                if (Membership.FindUsersByName(c.Username) != null)
                {
                    <tr>
                        @{ string roleName = ""; }
                        <td>@Html.ActionLink(@c.Username, "ViewAccount", "Account", new { id = @c.Username, Area = "" }, null)</td>
                        <td>@foreach (String role in @Roles.GetRolesForUser(@c.Username))
                            {
                                roleName = role;
                                @(role + " ")
                            }</td>
                        <td>@c.DateOfBirth</td>
                        <td>@Membership.GetUser(c.Username).CreationDate</td>
                        <td>@Membership.GetUser(c.Username).LastActivityDate</td>
                        <td>
                        @{
                            Html.RenderPartial("UserSecurityView", new UserSecurityViewModel
                                                                       {
                                                                           IsBanned = !Membership.GetUser(c.Username).IsApproved,
                                                                           Username = c.Username,
                                                                           Role = roleName,
                                                                       });
                        }
                        </td>

                    </tr>
                }
                
            }    
        </table>
        <br/><br/><br/>
<div id="pagerForm" class="pager @Html.GetColor(Request.Cookies["color"])">
    @Html.PageLinks(Model.PagingInfo, i => Url.Action("Index","Account", new { page = i, pageSize = Model.PagingInfo.ItemsPerPage, area="Admin" }))
</div>